﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace CSVExportImport
{

    public class WriterWrapper
    {
        TextWriter writer;
        public WriterWrapper(TextWriter writer)
        {
            this.writer = writer;
        }

        private bool hasElement = false;
        private bool newLine = true;
        private bool writeLine = false;

        public void WriteElement(String value)
        {
            if (writeLine)
            {
                writer.Write(Parameters.LINE_SEPARATOR);
                hasElement = false;
                newLine = true;
                writeLine = false;
            }
            if (hasElement)
            {
                writer.Write(Parameters.ITEM_SEPARATOR);
            }
            writer.Write(Parameters.FormatValue(value));
            hasElement = true;
            newLine = false;
        }
        public void WriteLine()
        {
            //writer.Write(Parameters.LINE_SEPARATOR);

            writeLine = true;
            //hasElement = false;
            //newLine = true;
        }
    }
}
